//
// Copyright (c) 2021 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package main

import (
	"cloud-export-iotkit-mqtt/pkg/service"
	"os"
)

const (
	serviceKey = "iotkit-export-mqtt"
)

func main() {
	// turn off secure mode for examples. Not recommended for production
	_ = os.Setenv("EDGEX_SECURITY_SECRET_STORE", "false")

	// 正式环境需注释掉
	localMode("192.168.0.107", "59998", "192.168.6.129")

	iitaService := service.OpenIitaService{}
	iitaService.Initialize(serviceKey)
	iitaService.Run()

	os.Exit(0)
}

// localMode 本地调试模式
// serverHost：驱动服务监听地址
// serverPort：驱动服务监听端口号
// edgeXServerHost：EdgeX服务地址
// 示例： localMode("127.0.0.1", "59998", "192.168.16.88")
func localMode(serverHost, serverPort, edgeXServerHost string) {
	_ = os.Setenv("SERVICE_HOST", serverHost)
	_ = os.Setenv("SERVICE_PORT", serverPort)
	_ = os.Setenv("REGISTRY_HOST", edgeXServerHost)
	_ = os.Setenv("CLIENTS_CORE_DATA_HOST", edgeXServerHost)
	_ = os.Setenv("CLIENTS_CORE_METADATA_HOST", edgeXServerHost)
	_ = os.Setenv("MESSAGEQUEUE_HOST", edgeXServerHost)
}
